from pydantic import BaseModel
from typing import List, Optional, Dict, Any

class ShipmentAllocation(BaseModel):
    """
    货物分配模型
    """
    shipment_id: int
    origin: str
    destination: str
    assigned_route: str
    cost: float
    preference_rank: int

class RouteUtilization(BaseModel):
    """
    路线利用率模型
    """
    route_id: str
    capacity: int
    used_capacity: int
    utilization_rate: float
    assigned_shipments: int

class MatchingSummary(BaseModel):
    """
    匹配摘要模型
    """
    total_shipments: int
    matched_shipments: int
    unmatched_shipments: int
    total_capacity: int
    matched_capacity: int
    stability: bool
    execution_time: float
    iterations: int

class MatchingResult(BaseModel):
    """
    匹配结果模型
    """
    summary: MatchingSummary
    shipments_allocation: List[ShipmentAllocation]
    routes_utilization: List[RouteUtilization]

class ProcessStep(BaseModel):
    """
    过程步骤模型
    """
    iteration: int
    action: str
    blocking_pairs: int
    matched_shipments: int
    details: Optional[Dict[str, Any]] = None

class MatchingProcess(BaseModel):
    """
    匹配过程模型
    """
    steps: List[ProcessStep]